package com.douqu.game.activity;

import com.bean.core.util.Utils;
import com.douqu.game.activity.gui.MainFrame;
import com.douqu.game.core.factory.LoadFactory;
import com.douqu.game.core.util.LogUtils;

import javax.swing.*;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-03-07 14:48
 */
public class StartServer {

    public static void main(String[] args)
    {
        if (args.length > 0)
        {
            LoadFactory.FIXED_CONFIG_PATH = args[0];
        }
        if (args.length > 1)
        {
            LoadFactory.DYNAMIC_CONFIG_PATH = args[1];
        }

        LogUtils.warn("FIXED_CONFIG_PATH ========> ", LoadFactory.FIXED_CONFIG_PATH);
        LogUtils.warn("DYNAMIC_CONFIG_PATH ==========> ", LoadFactory.DYNAMIC_CONFIG_PATH);

        SpringServer.args = args;

        MainFrame mainFrame = new MainFrame();
        GameServer.getInstance().setMainFrame(mainFrame);

        int activityId = 0;
        try{
            activityId = Integer.parseInt(args[0]);
        }catch (Exception e){
            String idStr = JOptionPane.showInputDialog(null, "请输入活动ID!");
            if(Utils.isNullOrEmpty(idStr))
            {
                System.exit(0);
                return;
            }
            try{
                activityId = Integer.parseInt(idStr);
            }catch (Exception e1){
                JOptionPane.showMessageDialog(null, "活动ID输入错误!");
                System.exit(0);
                return;
            }
        }

        GameServer.getInstance().getActivityCampManager().setId(activityId);

        mainFrame.showFrame();
    }
}
